package com.skstudio.report;

import java.util.ArrayList;

public class ReportCpuSpeed extends ReportBase {
	public static class DataSpeed {
		public long mCoreId = 0;
		public long mMax = 0, mMin = 0, mCur = 0;
		
		public void Read(byte[] buffer, int offset) {
			mCoreId = getCxxUnsignedLong(buffer, offset + 0);
			mMax = getCxxUnsignedLong(buffer, offset + 4) / 1000;
			mMin = getCxxUnsignedLong(buffer, offset + 8) / 1000;
			mCur = getCxxUnsignedLong(buffer, offset + 12) / 1000;
		}
	}
	
	public ArrayList < ArrayList < DataSpeed > > mDataList = new ArrayList < ArrayList < DataSpeed > >();
	
	@Override
	public void parse(byte[] buffer, int offset)
	{
		DataSpeed dc = new DataSpeed();
		dc.Read(buffer, offset);
		if (dc.mCoreId >= mDataList.size()) {
			ArrayList < DataSpeed > qdc= new ArrayList < DataSpeed >();
			mDataList.add(qdc);
		}
		ArrayList < DataSpeed > qdc = mDataList.get((int)dc.mCoreId);
		if (qdc.size() == getMaxQueueSize()) {
			qdc.remove(0);
		}
		qdc.add(dc);	
	}
	
	@Override
	public void reset() {
		mDataList.clear();
	}
}
